export const isCode = (node) => node.type === 'code';
/**
 * Converts "`code`" to "<pre><code>code</code></pre>"
 */
export const convertCode = (node) => {
    node.type = 'mdxJsxFlowElement';
    node.name = 'pre';
    const attributes = [
        {
            type: 'mdxJsxAttribute',
            name: 'tabindex',
            value: '0',
        },
    ];
    const className = node.lang
        ? {
            type: 'mdxJsxAttribute',
            name: 'class',
            value: `language-${node.lang}`,
        }
        : undefined;
    if (className) {
        attributes.push(className);
    }
    node.attributes = attributes;
    const codeChild = {
        type: 'mdxJsxFlowElement',
        name: 'code',
        children: [
            {
                type: 'text',
                value: node.value,
            },
        ],
        attributes: className ? [className] : [],
    }; // the children type is malformed
    node.children = [codeChild];
};
